package com.as3.timbot.transitions
{
	import com.as3.timbot.command.AbstractCommand;
	import com.as3.timbot.transitions.TweenLite;
	import com.as3.timbot.transitions.Equations;
	import flash.display.DisplayObject;
	
	public class TweenCommand extends AbstractCommand
	{
		private var __tween:Object;
		private var __clip:DisplayObject;
		private var __duration:Number;
		private var __hijack:Function;
		private var __hijackParams:Array;

		public function TweenCommand(clip:DisplayObject,duration:Number,tween:Object):void
		{
			//extract the callback from the tween object
			__hijack = tween.onComplete;
			__hijackParams = tween.onCompleteParams;
			///replace for command compatibility
			tween.onComplete = onFinishTween;
			tween.onCompleteParams = new Array([1,1]);
			__tween = tween;
			__clip = clip;
			__duration = duration;
		}
		override public function execute():void
		{
			super.begin();
			///////////testing below//////////////
			TweenLite.to(__clip, __duration, __tween);
			
		}
		private function onFinishTween(x:Array):void
		{
			trace("tweening has finished in command");
			__hijack.apply(null,__hijackParams);
			super.end();
		}
	}
}
//{x:120, ease:tw["easeoutback"], delay:1, onComplete:onFinishTween, onCompleteParams:[5, myHolder]}